package game.game.ia.state;

import java.util.List;

import astar.AStar;
import astar.IAstarMap;

import entity.Position;
import entity.object.EnemyEntity;
import game.engine.ia.ICleverEntity;
import game.game.ia.IGameIAModel;
import game.test.ia.IControllerEngine;

public class StateAgressive extends GameIAState
{
	public StateAgressive(IGameIAModel pModel)
	{
		super(pModel);
	}

	@Override
	public void executeState( IControllerEngine pController,  ICleverEntity pEntity )
	{
		IGameIAModel model = getModel();
		if ( pEntity.getTarget() != null )
		{
			EnemyEntity entity = (EnemyEntity) pEntity;
			//
			List<Position> positionPath = new AStar( (IAstarMap) model.getMap() ).searchPath( pEntity.getTarget().getPosition() , entity.getPosition() );
			if (positionPath.size() > 2 )
			{
				pController.changePosition( entity.getId() , positionPath.get( 1 ) );
			}
		}
	}

}
